<template>
    <div class="m-goods">
        <div class="goods-wrap maoyan">
            <div class="special-title">{{title}}</div>
            <div class="q-list">
                <ul>
                    <li v-for="(item,index) in movieTitle" :key="index" :class="{'active':tag === index}" @mouseenter="tab(index , item)">
                        {{item}}
                    </li>
                </ul>
            </div>
        </div>
        <div class="good-area clearfix">
            <el-carousel indicator-position="outside">
                <el-carousel-item v-for="item in 1" :key="item">
                    <div class="movie-item" v-for="(item,index) in movie" :key="index">
                        <img :src="item.img | setUrl">
                        <div class="movie-info">
                            <p class="score">
                                <b>观众评</b>
                                <span>{{item.sc}}</span>
                            </p>
                            <p class="name">{{item.nm}}</p>
                        </div>
                    </div>
                </el-carousel-item>
            </el-carousel>
        </div>
    </div>
</template>

<script>

export default{
    props:{
        title:{
            type: String,
            default: ''
        },
        movie:{
            type: Array,
            default: () => {
                return []
            }    
        }
    },
    data(){
        return{
            value: 4.5,
            tag: 0,
            movieTitle: ['正在热映' , '即将上映']
        }
    },
    methods:{
        tab(index , title){
            setTimeout(async() => {
                this.tag = index;
                let {status,data:{code,movie}} = await this.$axios.get('http://127.0.0.1:8082/scenes/maoyan' , {
                    params:{
                        limit: 5,
                        ci: 99
                    }
                });
                if(title === '正在热映'){
                    this.$emit('sendData' , movie.hot);
                }
                if(title === '即将上映'){
                    this.$emit('sendData' , movie.coming);
                }
            },200)
        }
    },
    filters:{
        setUrl(url){
            return url.replace('w.h/' , '');
        }
    }
}
</script>